package com.cqc.jdk8.Jio;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * @author cui
 * @description T
 * @date 2022/6/8
 **/
public class FileTest {


    @Test
    public void f1() throws IOException {
        File fileDir = new File("D:\\temp");
        File[] files = fileDir.listFiles();
        for (File file : files) {
            //filename=root.log,Path=D:\log\root.log
//            System.out.println("filename=" + file.getName() + ",Path=" + file.getPath());
            System.out.println(file.getCanonicalPath());
        }
    }
    @Test
    public void f2() throws IOException {
        //如果文件不存在，也不会报错。
        File file = new File("D:\\A/A.txt");
        boolean exists = file.exists();
        System.out.println(exists);
    }


}
